Skip to content

feat: dsh web-profile settings entry opening the bili Web UI (#1590) - #1619

Merged
ranxianglei merged 4 commits into
masterfrom
2026-09-28_dsh-bili-settings-entry
Sep 30, 2026
Merged

ranxianglei merged 4 commits into
masterfrom
2026-09-28_dsh-bili-settings-entry

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #1590

给 dsh 的 web 配置文件页增加一个「bili设置」入口,跳转到 bili Web UI(与已有的 /acp 链接互补)。中文说明见 #1590。

What changed

  • Host half (src/agent/dsh-native.ts): on webserver/index-inject (web-profile hosts only), pushes {kind:"global", name:"__BILI__", value:{origin}} into the index table. Origin = register.base (attach mode binds it synchronously; spawn mode binds it after bootstrap) falling back to the BILLION_CONTEXT_PROXY env var — published only while known, so at startup-time collection the entry degrades to a hint instead of a stale link.
  • Client half (src/agent/dsh-native-client.ts, new tsup entry → dist/agent/dsh-native-client.js): registers a settings.section slot (id bili, order 100, zh/en, label「bili设置」) that opens ${origin}/__bili/ in a new tab; shows a degraded hint when globalThis.__BILI__?.origin is absent ("run /acp first, or launch through bili dsh").
  • Resolvable shim (src/launcher.ts): the dsh client-module scanner resolves plugin packages by require.resolve walk-up from the profile dir and silently skips whatever fails to resolve (catch→null ⇒ no graph row ⇒ the browser half never attached for the legacy file:// patch entry). Fixed at the source: every bili dsh launch now writes a small resolvable package <DSH_HOME>/node_modules/billion-context (package.json exporting ./dsh, ./dsh/package.json, ./client, plus symlinks into bili's live dist bundles — self-healing across auto-updates, no second code copy), and dshPluginEntry() probes resolution from DSH_HOME before writing the patch file: bare name billion-context/dsh when resolvable, legacy file:// URL fallback when the shim is broken/missing. NODE_PATH now unconditionally prepends the base DSH_HOME's node_modules for all dsh lanes.

Behavior flags (old → new)

  1. New artifacts: bili dsh now creates <DSH_HOME>/node_modules/billion-context/ (+ overlay-home copy) on every launch — no such directory existed before. Symlinked into bili's own dist and refreshed each launch (no drift).
  2. Overlay patch entry name: was always file:///…/dist/agent/dsh-native.js; now bare billion-context/dsh whenever resolvable from DSH_HOME (file-URL fallback retained for broken shims).
  3. NODE_PATH: previously prepended only when a bare specifier already resolved from the dsh binary tree; now unconditionally prepends <base DSH_HOME>/node_modules for every dsh lane (persistent + overlay).
  4. package.json metadata surface: added exports "./client" + "./dsh/package.json" and "dsh.client" platform metadata — npm package metadata consumed by the dsh scanner, NOT the user config surface: ~/.config/billion-context/config.json, BILI_* env vars, and CLI flags are all unchanged.
  5. dsh web UI: additive settings section only; existing sections untouched. No wire/compression behavior change in either compression mode.

Pre-flight

  • typecheck clean; full suite: 3128 tests, 3112 pass, 0 fail, 16 skipped (gated); build ok.
  • Live E2E against the real system dsh (bili dsh web --no-open): proxy origin injected into index.html as globalThis.__BILI__; scanner graph row /plugins/billion-context/dsh/client.js?rev=… present and serving the client bundle (HTTP 200); shims self-healed in both base and overlay homes; .bili-acp.patch.yml carries the bare entry.
  • e2e-codex: preflight (E2E_CHECK=1) passes; the full run could not complete locally because the local model upstream documented in tests/e2e/README.md is down in this environment (unreachable, no local model service available). The diff is additive to the dsh lane only (launcher dsh branch, new src/agent/dsh-native* files, package metadata) — codex/Responses pipeline code paths are byte-identical — and CI (ci-e2e.yml) auto-runs e2e-codex on this PR since the diff touches src/agent/**.

@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-09-28_dsh-bili-settings-entry (3e838ab)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.1749-pr.1619.0609fb7

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr1619.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 收到。这是 agent 已完成的 PR(#1590),按规不重做——正在拉取分支核对代码 + 查 CI 状态,稍后给出 review 结论(含既有行为回归审查)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Review 完成(按 ework-agent-pr 规则:不重做,拉分支核对代码 + CI)。过程中在 PR 分支上直接修了两个小问题(各一个独立标注 commit,已 push),详见下文。

① 原 issue 方向(#1590)

方向成立且与 owner 确认一致:#1590 floor 4「确认」拍板的方案(web-profile only、origin = register.base ?? BILLION_CONTEXT_PROXY 且只在已知时发布、缺失时降级为提示文案、package.json 元数据属 npm 元数据而非用户配置面)与本 PR 实现逐条对应。dsh 双脸插件包(host apply + dsh.client/./client browser 模块)是 dsh 原生机制,没有引入私有通道。✓

② 回归审查(触碰路径的既有行为清点)

  • runLaunch dsh 分支:既有行为(BILLION_CONTEXT_PROXY/DEEPSEEK_BASE_URL/HTTPS_PROXY/SSL_CERT_FILE/NODE_EXTRA_CA_CERTS 注入、HTTP_PROXY/NO_PROXY 剥离、loopback overlay 重写、--patch 拼接顺序、.bili-acp.patch.yml 中 compaction-basic auto:false 行、PI_CACHE_RETENTION)逐项核对——测试断言全部保留,patch 文件格式不变,仅 entry name 取值变化。✓ 保持
  • entry name(flag fix: address all code review findings (condense, routing, session-id, dead code) #2):file://… → bare billion-context/dsh(可解析时),file-URL fallback 保留给坏 shim。有意变更,已披露。✓
  • 新产物(flag fix: keep system prompt byte-stable for prefix cache #1):<DSH_HOME>/node_modules/billion-context/ symlink shim,每次 launch 刷新、自愈跨 auto-update。有意新增,已披露。✓
  • NODE_PATH(flag Use kernel renderTags:"text-only" + forbid tag echoing in prompt #3):⚠️ PR 描述的 "previously" 不准确——master 上 根本没有任何 dsh NODE_PATH 逻辑(git grep origin/master 为空),"previously prepended only when…" 描述的是本 PR 开发中的中间状态。真实 old→new = 无 → 对 dsh 子进程无条件前置 <base DSH_HOME>/node_modules。变更本身仍属已披露范围;语义上 NODE_PATH 在本地 node_modules 走查失败后才被咨询,不会遮蔽可解析包;bili 宿主进程不受影响(env 是子进程副本)。风险低。
  • package.json 元数据(flag feat: OpenAI Responses API support (/v1/responses) #4):纯增量 subpath exports + dsh.client.platform,用户配置面(config.json / BILI_* / CLI flags)零改动,给deepseek定制一个跳转到状态的链接 #1590 floor 4 已有 owner 预签。✓
  • 压缩管线:diff 仅触及 dsh lane(launcher dsh 分支、新 src/agent/dsh-native*、package 元数据),codex/Responses/OpenAI 管线代码逐字节未动;两种压缩模式均不受影响。CI e2e(真实 codex 全流程)自动触发且绿。✓
  • tsup.config.ts 数组化:主构建先跑(clean)、client 追加(no clean),顺序安全;build-artifact job 绿,dist-import-annotations 检查 OK;npm files 含整个 dist,client bundle 会随包发布。✓
  • writeDshAcpPatch(dshHome, entryName?):可选参数,向后兼容,唯一调用点已更新。✓

③ 代码审查——发现并已直接修复的两个问题

  1. shim 版本号 off-by-one(真缺陷,已修):writeDshClientShim 用 path.dirname(path.dirname(hostBundle)) 定位 package.json,但 selfDistFile() = <root>/dist/<name>,两次 dirname 落在 <root>/dist——那里没有 package.json,catch 静默吞掉,所有 shim 永远 stamp 0.0.0。已改为直接读 selfPackageRoot(),并加了回归测试(dist 存在时校验 shim 版本 == 仓库版本,无构建则 skip)。commit ac96cc2d。
  2. 测试确定性漏洞(环境相关,已修):原测试把防 self-name 解析的 guard package.json 放在 home/dshhost/——它不在 overlay 探针锚点的 walk-up 链上。当 os.tmpdir() 位于 billion-context checkout 内部(本沙箱即如此)时,tsx resolver 会先拿最近外层 package.json 做 self-name 匹配再走 node_modules,探针解析到 checkout 自身的 package.json 而非 fixture shim,bare-entry 断言在已构建树上失败(我本地复现并逐层验证了机制;plain Node 无此问题——node_modules 优先,所以 CI 和真实 dsh scanner 都不受影响,纯测试面)。guard 移到 home 根。commit 937269f7。

接受的非阻塞边缘(不拦):shim 每次 launch rm-rf 重写,若用户手动往 <DSH_HOME>/node_modules/billion-context 装过东西会被覆盖(持久 lane 装在 profiles 里,不走这里);attach 目标宕机瞬间 settings 入口显示指向该 origin 的链接而非降级提示(proxy 本就不可达,bili 自愈后恢复)。

安全面:client 端 origin 来自服务端 index 注入(非浏览器输入),无 XSS 面;window.open(..., "noopener,noreferrer");文案均为 text node。

④ 测试有效性

新测试有牙:tsup wrapper 形状(loader id、factory 仅 require react)、shim 布局 + symlink realpath、resolution 探针的三级 fallback 阶梯(bare → stale-shim file:// → no-shim file://)、patch 内容、NODE_PATH 前缀——这个 feature 回归时抓得住。我补的版本 stamp 测试钉住 ③.1。

⑤ diff 整洁度

8 文件全部与 dsh lane 目的相关,无空行/重排噪音、无锁文件连带、无跑题文件。我的两个 commit 均为小而有标注的追加。

结论

  • 原 head 27d6063a:CI 13/13 全绿(含 e2e-codex、hermetic registry、real dsh/pi/opencode/codex lanes)。
  • 新 head 937269f7(含我的两个修复 commit):CI 重跑中,e2e 与 version-guard 已绿,其余 in_progress。
  • 本地验证:typecheck 干净;launcher + dsh-settings-ui 定向套件 240/240 通过(含两个新测试);build 成功;探针机制独立复现脚本验证。

等 937269f7 的 CI 全绿即可合并(合并由人来操作)。


中文一句话:审了 PR #1619(dsh web 设置页 bili 设置入口)——方向与 #1590 owner 确认一致、对既有行为无回归(仅 dsh lane 增量,压缩路径字节级未动);直接在 PR 分支修了两个小问题(shim 版本号 off-by-one 恒写 0.0.0、tmpdir 在仓库内时测试因 tsx self-name 解析不确定),CI 全绿后可合并。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 CI 确认:新 head 937269f7(含两个修复 commit)13/13 全绿——test(ubuntu/windows × 24/22)、e2e-codex、hermetic registry e2e、build-artifact、version-guard、real dsh/pi/opencode/codex lanes 全部 success。可以合并了(合并由你操作):#1619

ework-agent added 3 commits September 30, 2026 21:54
Adds a browser-side dsh client bundle (dsh.client platform:web) that
registers a "settings.section" page (id bili, order 100) in the dsh
web profile's settings nav. The host half injects globalThis.__BILI__
{origin} via webserver/index-inject when the proxy origin is known at
startup (attach mode binds register.base synchronously; spawn mode
degrades until the proxy is up). The entry opens <origin>/__bili/ in a
new tab, or shows an honest degraded hint when the origin is unknown.

Overlay-lane patch entries now use the bare specifier
"billion-context/dsh" when resolvable from the dsh tree (the scanner
anchors its require.resolve there too); the file:// URL remains the
fallback. NODE_PATH is prepended for the dsh child so split-prefix
installs still resolve. New exports: ./client and ./dsh/package.json.
writeDshClientShim read the version from path.dirname(path.dirname(hostBundle)) — but selfDistFile() is <root>/dist/<name>, so that arithmetic lands on <root>/dist, whose package.json does not exist; the catch swallowed it and every shim was stamped 0.0.0. Read from selfPackageRoot() directly, and pin the behavior with a regression test (skips when no dist build is present).
…r is inside a checkout (#1590)

The existing guard package.json sat under home/dshhost/, which is NOT on the overlay probe anchor's walk-up chain. When os.tmpdir() lives inside a billion-context checkout (this sandbox), tsx's resolver matches the checkout's own self-named package.json before walking node_modules, so dshPluginEntry probed the checkout instead of the fixture shim and the bare-entry assertion failed on built trees. Move the guard to the home root so the nearest enclosing package.json can never be billion-context from either anchor.
@ranxianglei
ranxianglei force-pushed the 2026-09-28_dsh-bili-settings-entry branch from 937269f to 1b73937 Compare September 30, 2026 13:56
… for both lanes (#1590)

dsh's client-module scanner (dsh-client-modules, CLI 0.1.5-rc.x and desktop
0.2.0-rc.2 alike) requires an entry NAME to be a package-root specifier:
exactPackageSpecifier returns undefined for any non-scoped specifier
containing '/', so the graph row is silently dropped and the browser half
never loads. The host half was unaffected (loader import resolves subpaths
fine), which is why the injection worked while the settings entry never
appeared.

- launcher --patch entry + shim: bare 'billion-context'; shim exports gain
  '.' (root import = host half). dshPluginEntry now probes that the ROOT
  specifier resolves to a file ending agent/dsh-native.js — a foreign or
  stale install whose '.' points elsewhere degrades to the legacy file URL
  instead of importing the wrong module into dsh.
- market-install lane: dsh.bundle.patch.yml name -> bare root, and the
  package exports['.'] moves from the CLI entry to the dsh host half (the
  dsh loader imports the bare root). opencode is unaffected either way:
  1.18.x resolvePackageEntrypoint only reads exports['./server'] when the
  exports map is a record, and 2.x Host.resolve tries ['server',''] in
  order — the root is never reached while ./server exists.
- browser bundle banner id matches the graph row id (package name).
- tests: launcher fixtures + negative case (shim '.' -> other file falls
  back to file URL), settings-ui registration id, index-entry-guard pins
  exports['.'] to the dsh host half and its import inertness.
@ranxianglei

Copy link
Copy Markdown
Owner Author

Rebased onto current master and fixed a real defect found while verifying locally: the browser half never actually loaded on the dsh versions tested (CLI 0.1.5-rc.2/rc.3, desktop 0.2.0-rc.2).

Root cause

dsh's client-module scanner (@deepseek-ai/dsh-client-modules/lib/index.js — identical in CLI and desktop app) requires the plugin entry name to be a package-root specifier. exactPackageSpecifier returns undefined for any non-scoped specifier containing /, so locatePkgJson bails and the graph row is silently dropped:

function exactPackageSpecifier(spec) { if (spec.startsWith("@")) ...; const i = spec.indexOf("/"); if (i === -1) return spec; /* subpath */ return void 0; }
// locatePkgJson: if (!pathLike && expectedPackageName === void 0) return void 0;

name: billion-context/dsh therefore loads the host half fine (the loader's import(specifier) resolves exports["./dsh"]) but the client half never registers — __BILI__ appears in the HTML while the settings section never shows. That asymmetry is exactly what we observed on a live isolated instance.

Fix (937269f → 3e838ab)

lane before after
launcher --patch + shim billion-context/dsh, shim exports ./dsh bare billion-context, shim exports gain "." (root import = host half); dshPluginEntry probes that the ROOT specifier resolves to a file ending agent/dsh-native.js, else falls back to the legacy file URL
market install (dsh.bundle.patch.yml) billion-context/dsh bare billion-context, and package exports["."] moves from the CLI entry to ./dist/agent/dsh-native.js (the dsh loader imports the bare root)
browser bundle banner id billion-context/dsh banner id billion-context (must equal the graph row id / package name)

opencode is unaffected by the root-export change: 1.18.x resolvePackageEntrypoint only reads exports["./server"] whenever the exports map is a record (the root is never consulted), and 2.x Host.resolve tries ["server", ""] in order — ./server exists, so the root is never reached. A new index-entry-guard test pins exports["."] to the dsh host half and its import inertness so the root can't silently go back to the CLI entry (importing the bare name inside dsh would then detonate the CLI).

Verification (real systems, both platforms)

Linux CLI (dsh 0.1.5-rc.2, isolated DSH_HOME=/tmp/…): __BILI__={origin:…} injected ✓ · __DSH_BOOT__ graph row /plugins/billion-context/client.js ✓ · bundle HTTP 200 ✓ · /__bili/ (bili Web UI) 200 ✓.

Windows desktop app (0.2.0-rc.2, real NSIS install, profile ~/.dsh/profiles/desktop, tarball install of this branch):

  • host half: plugin spawned the proxy from the profile install (node …desktop\node_modules\billion-context\dist\index.js start --port 18787), __bili/ → 200
  • injection: renderer globalThis.__BILI__ = {"origin":"http://127.0.0.1:18787"}
  • browser half: __DSH_BOOT__ contains a billion-context row; CDP-forced reload fetched the combo bundle (…,billion-context/client.js) → HTTP 200, listed alongside dsh's own built-ins

Gates on the rebased head: typecheck ✓ · launcher + dsh-settings-ui + index-entry-guard + plugin-install-opencode 266/266 ✓ · build ✓.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

给deepseek定制一个跳转到状态的链接

1 participant